import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import { airportList } from '@apps/ant-bus/src/views/business/airport/data/api';

export const columns: BasicColumn[] = [
  {
    title: '被赠送人姓名',
    dataIndex: 'userName',
    width: 100,
  },
  {
    title: '被赠送人手机号',
    dataIndex: 'userMobile',
    width: 100,
  },
  {
    title: '来源',
    dataIndex: 'optUserType',
    width: 100,
    customRender: ({ record }: Recordable) => {
      const optUserTypeArray = [
        { label: '销售端', value: 1 },
        { label: '后台', value: 2 },
      ];
      const optUserType: any = optUserTypeArray.find(item => item.value == record.optUserType);
      if (optUserType) {
        return optUserType.label;
      }
      return '';
    },
  },
  {
    title: '操作人',
    dataIndex: 'optUserName',
    width: 100,
  },
  {
    title: '商品',
    dataIndex: 'goodsName',
    width: 100,
  },
  {
    title: '机场',
    dataIndex: 'airportName',
    width: 100,
  },
  {
    title: '赠送张数',
    dataIndex: 'goodsNum',
    width: 100,
  },
  {
    title: '备注',
    dataIndex: 'remark',
    width: 100,
  },
  {
    title: '创建日期',
    dataIndex: 'createTime',
    width: 150,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'startDate',
    label: '开始日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '结束日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'userName',
    label: '姓名',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'userMobile',
    label: '手机号',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'optUserType',
    label: '来源',
    component: 'Select',
    colProps: { span: 5 },
    componentProps: {
      options: [
        { label: '销售端', value: 1 },
        { label: '后台', value: 2 },
      ],
    },
  },
  {
    field: 'optUserName',
    label: '操作人',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'airportId',
    label: '机场',
    component: 'ApiSelect',
    colProps: { span: 5 },
    componentProps: {
      api: airportList,
      params: {},
      labelField: 'airportName',
      valueField: 'airportId',
      showSearch: true,
      immediate: true,
    },
  },
];
